<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='商品分类管理',active='cate'">
<head th:replace="/manage/header::headerFragment(title,active)">
  <!-- 引入 layui.css -->
  <link href="//unpkg.com/layui@2.8.0/dist/css/layui.css" rel="stylesheet">

  <!-- 引入 layui.js -->
  <script src="//unpkg.com/layui@2.8.0/dist/layui.js"></script>
</head>
<body>
<div th:replace="/manage/header::header-body"></div>
<div class="row">
  <div class="col-2">
    <div th:replace="/manage/leftnav::leftnav"></div>
  </div>
  <div class="col-10 content-page">
    <div class="row" style="padding: 20px 0 0 40px">
      <a th:href="@{'/scenicSpot/toAddPage'}" class="btn btn-primary col-2">新增景点信息</a>
    </div>

    <div class="panel panel-default" style="margin-left: 10px">
      <!-- Default panel contents -->
      <div class="panel-heading">景点列表</div>
      <table class="table table-striped table-bordered">
        <thead>
        <tr>
          <th>#</th>
          <th>景点名称</th>
          <th>图片</th>
          <th>地址</th>
          <th>介绍</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>

        <tr th:each="scenicspots, status : ${scenicspots}">
          <td th:text="${status.count}"></td>
          <td th:text="${scenicspots.scenicspot_name}"></td>
          <td><img th:src="@{${scenicspots.scenicspot_img}}" width="60" height="60"></td>
          <td th:text="${scenicspots.scenicspot_addr}"></td>
          <td th:text="${scenicspots.scenicspot_introduce}"></td>
          <td>
            <a th:href="@{'/scenicSpot/updateScenicSpot/'+${scenicspots.scenicspot_id}}" class="btn btn-primary">更新</a>
            <a th:href="@{'/scenicSpot/deleteScenicSpot/'+${scenicspots.scenicspot_id}}" class="btn btn-primary delete-btn">删除</a>
          </td>
        </tr>
        </tbody>
      </table>
      <div class="row">
        <!--  <div th:replace="common/paging :: pageAdminNav(${goods})"></div>-->
      </div>
    </div>
  </div>
</div>

<script>
  document.addEventListener('DOMContentLoaded', function() {
    var deleteButtons = document.querySelectorAll('.delete-btn');
    deleteButtons.forEach(function(button) {
      button.addEventListener('click', function(event) {
        event.preventDefault();
        var confirmDelete = confirm('确定要删除这个景点吗？');
        if (confirmDelete) {
          window.location.href = this.getAttribute('href');
        }
      });
    });
  });
</script>

</body>
</html>
